package top.haijunit.navi.auth.domain;

import com.alibaba.excel.annotation.ExcelIgnore;
import com.alibaba.excel.annotation.ExcelProperty;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.Email;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.Pattern;
import lombok.Data;
import org.hibernate.validator.constraints.Length;
import top.haijunit.framework.servlet.annotation.Desensitize;
import top.haijunit.framework.servlet.annotation.DesensitizeType;
import top.haijunit.framework.validation.ValidChecks;
import top.haijunit.navi.auth.core.WorkConstant;

/**
 * 用户信息
 *
 * @author zhanghaijun
 * @since 2024-10-25
 */
@Data
@Schema(description = "用户信息")
public class UserInfo {

    /**
     * 用户编码
     */
    @Schema(description = "用户编码", example = WorkConstant.DEFAULT_ID_STR)
    @NotBlank(message = "用户编码不能为空", groups = {ValidChecks.GroupEdit.class})
    private Long userId;

    /**
     * 用户名
     */
    @Schema(description = "用户名", example = "张晨瑾")
    @NotBlank(message = "用户名不能为空", groups = {ValidChecks.GroupAdd.class, ValidChecks.GroupEdit.class})
    @Length(min = 2, max = 16, message = "用户名长度在2-16之间", groups = {ValidChecks.GroupAdd.class, ValidChecks.GroupEdit.class})
    @ExcelProperty(value = "用户名")
    private String username;

    /**
     * 用户昵称
     */
    @Schema(description = "用户昵称", example = "zhangchenjin")
    @Length(min = 2, max = 32, message = "用户昵称长度在2-32之间", groups = {ValidChecks.GroupAdd.class, ValidChecks.GroupEdit.class})
    @ExcelProperty(value = "用户昵称")
    private String nickname;

    /**
     * 用户密码
     */
    @Desensitize(type = DesensitizeType.PASSWORD)
    @Schema(description = "用户密码", hidden = true)
    @ExcelIgnore
    private String userPassword;

    /**
     * 用户邮箱
     */
    @Desensitize(type = DesensitizeType.EMAIL)
    @Schema(description = "用户邮箱", example = "zhangchenjin@163.com")
    @Email(message = "邮箱格式不正确", groups = {ValidChecks.GroupAdd.class, ValidChecks.GroupEdit.class})
    @ExcelProperty(value = "用户邮箱")
    private String email;

    /**
     * 手机号码
     */
    @Desensitize(type = DesensitizeType.PHONE)
    @Schema(description = "手机号码", example = "18266668888")
    @Pattern(regexp = "^1[3456789]\\d{9}$", message = "手机号码格式不正确", groups = {ValidChecks.GroupAdd.class, ValidChecks.GroupEdit.class})
    @ExcelProperty(value = "手机号码")
    private String phone;

}
